# -*- coding:utf-8 -*-
import urllib.request
import re
import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')

page = 1
url =  'http://www.qiushibaike.com/hot/page/' + str(page)
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers =  {'User-Agent':user_agent}
try:
	request = urllib.request.Request(url,headers=headers)
	response = urllib.request.urlopen(request)
	content = response.read().decode('utf-8')
	pattern = re.compile('<div.*?author">.*?<a.*?<img.*?>(.*?)</a>.*?<div.*?'+
                         'content">(.*?)<!--(.*?)-->.*?</div>(.*?)<div class="stats.*?class="number">(.*?)</i>',re.S)
	items = pattern.findall(content)
	for item in items:
		print(item)
except urllib.request.URLError as e:
	if hasattr(e,'code'):
		print(e.code)
	if hasattr(e,'reason'):
		print(e.reason)

pattern = re.compile('[a-zA-Z]')
result = pattern.findall('as3SiOPdj#@23awe')
print (result)
# <div class="article block untagged mb15 typs_hot" id="qiushi_tag_121364023">


# <div class="author clearfix">
# <a href="/users/21610887/" target="_blank" rel="nofollow" style="height: 35px" onclick="_hmt.push(['_trackEvent','web-list-author-img','chick'])">

# <img src="//pic.qiushibaike.com/system/avtnew/2161/21610887/thumb/20181208114021.jpg?imageView2/1/w/90/h/90" alt="墨海烟云">
# </a>
# <a href="/users/21610887/" target="_blank" onclick="_hmt.push(['_trackEvent','web-list-author-text','chick'])">
# <h2>
# 墨海烟云
# </h2>
# </a>
# <div class="articleGender manIcon">29</div>
# </div>

# <a href="/article/121364023" target="_blank" class="contentHerf" onclick="_hmt.push(['_trackEvent','web-list-content','chick'])">
# <div class="content">
# <span>


# 二货女友有多二？<br>昨晚从超市里买了一大堆东西，骑着电炉子载女友回家，二货路上不停的手伸衣服挠我痒，跟她说“别闹了，小心摔了。。”<br>她“哦～”然后突然在后座上站起来，挥舞着双手说“我要飞啦，，”她的话音未落，电炉子一个不稳摔倒了，直接把女友飞出去了，脸朝下那种……

# </span>

# </div>
# </a>
# <!-- 图片或gif -->


# <div class="stats">
# <!-- 笑脸、评论数等 -->


# <span class="stats-vote"><i class="number">1401</i> 好笑</span>
# <span class="stats-comments">
# <span class="dash"> · </span>
# <a href="/article/121364023" data-share="/article/121364023" id="c-121364023" class="qiushi_comments" target="_blank" onclick="_hmt.push(['_trackEvent','web-list-comment','chick'])">
# <i class="number">66</i> 评论
# </a>
# </span>
# </div>
# <div id="qiushi_counts_121364023" class="stats-buttons bar clearfix">
# <ul class="clearfix">
# <li id="vote-up-121364023" class="up">
# <a href="javascript:voting(121364023,1)" class="voting" data-article="121364023" id="up-121364023" rel="nofollow" onclick="_hmt.push(['_trackEvent','web-list-funny','chick'])">
# <i></i>
# <span class="number hidden">1413</span>
# </a>
# </li>
# <li id="vote-dn-121364023" class="down">
# <a href="javascript:voting(121364023,-1)" class="voting" data-article="121364023" id="dn-121364023" rel="nofollow" onclick="_hmt.push(['_trackEvent','web-list-cry','chick'])">
# <i></i>
# <span class="number hidden">-12</span>
# </a>
# </li>
# <li class="comments">
# <a href="/article/121364023" id="c-121364023" class="qiushi_comments" target="_blank" onclick="_hmt.push(['_trackEvent','web-list-comment01','chick'])">
# <i></i>
# </a>
# </li>
# </ul>
# </div>
# <div class="single-share">
# <a class="share-wechat" data-type="wechat" title="分享到微信" rel="nofollow">微信</a>
# <a class="share-qq" data-type="qq" title="分享到QQ" rel="nofollow">QQ</a>
# <a class="share-qzone" data-type="qzone" title="分享到QQ空间" rel="nofollow">QQ空间</a>
# <a class="share-weibo" data-type="weibo" title="分享到微博" rel="nofollow">微博</a>
# </div>
# <div class="single-clear"></div>


# <a href="/article/121364023" class="indexGodCmt" onclick="_hmt.push(['_trackEvent','web_list_comment-popular','chick'])" rel="nofollow" target="_blank">
# <div class="cmtMain">
# <span class="cmt-god"></span>






# <span class="cmt-name">吃了两碗又盛：</span>
# <div class="main-text">
# 骑电炉子屁股不烫吗？
# <div class="likenum">
# <img src="//static.qiushibaike.com/images/newarticle/like@1.5.png?v=b7f830b3bb97b559891af61444d3b4ad">


# 80

# </div>
# </div>
# </div>
# </a>

# </div>